/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <gtest/gtest.h>
#include "sle_host_impl.h"
#include "cmd_input.h"
#include <vector>
#include <memory>
#include <cstring>
#include <iterator>

namespace OHOS {
namespace NearLink {
namespace SleStandard {
namespace {

using namespace testing::ext;

static SleHost *g_SleHost;
static std::shared_ptr<SleHostCallback> g_Callback;


} // namespace

class HostHandlerTest : public testing::Test {
public:
    static void SetUpTestCase();
    static void TearDownTestCase();
    void SetUp();
    void TearDown();
};

void HostHandlerTest::SetUpTestCase() {}

void HostHandlerTest::TearDownTestCase() {}

void HostHandlerTest::SetUp() {
    if (g_SleHost == nullptr) {
        g_SleHost = &SleHost::GetDefaultHost();
    }
}

void HostHandlerTest::TearDown() {}

// 测试启用SLE功能是否能正确返回错误码     需要写一下
// HWTEST_F(HostHandlerTest, SleEnableTest001, TestSize.Level1) {
//     SleErrorCode ret = g_SleHost->EnableSle();
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }


/******************************************************************************************************************** */
// 测试禁用SLE功能时是否能正确处理已经禁用的情况
// HWTEST_F(HostHandlerTest, SleDisableTest001, TestSize.Level1) {
//     SleErrorCode ret = g_SleHost->DisableSle();
//     EXPECT_EQ(ret,SLE_ERR_CHECKOUT_FAILED);
// }



/******************************************************************************************************************** */





// // 测试获取SLE状态是否能正确返回状态码
// HWTEST_F(HostHandlerTest, GetSleStateTest001, TestSize.Level1) {
//     SleDeviceState sleHostState;
//     SleErrorCode ret = g_SleHost->GetSleState(sleHostState);
//     EXPECT_EQ(ret, SLE_ERR_IPC_TRANS_FAILED);
// }

// // 测试获取主机名是否能正确返回错误码
// HWTEST_F(HostHandlerTest, GetHostNameTest001, TestSize.Level1) {
//     std::string name;
//     SleErrorCode ret = g_SleHost->GetHostName(name);
//     EXPECT_EQ(ret, SLE_ERR_IPC_TRANS_FAILED);
// }

// // 测试设置主机名是否能正确处理错误情况
// HWTEST_F(HostHandlerTest, SetHostNameTest001, TestSize.Level1) {
//     std::string name = "001";
//     SleErrorCode ret = g_SleHost->SetHostName(name);
//     EXPECT_EQ(ret, SLE_ERR_IPC_TRANS_FAILED);
// }


/******************************************************************************************************************** */
// 测试启动流监控功能是否能正确返回错误码
// HWTEST_F(HostHandlerTest, StartFlowMonitor001, TestSize.Level1) {
//     SleErrorCode ret = g_SleHost->StartFlowMonitor();
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }


/******************************************************************************************************************** */
// 测试停止流监控功能是否能正确返回错误码
// HWTEST_F(HostHandlerTest, StopFlowMonitorTest001, TestSize.Level1) {
//     SleErrorCode ret = g_SleHost->StopFlowMonitor();
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }



/******************************************************************************************************************** */
// 测试设置主机地址功能是否能够正确处理错误情况
// HWTEST_F(HostHandlerTest, GetHostAddressTest001, TestSize.Level1) {
//     SleDeviceAddress hostAddr = {
//         .addrType = SLE_RANDOM_ADDRESS_TYPE,
//     };
//     char addr[18];
//     strcpy(addr, "00:11:aa:bb:f1:6b");
//     Str2Mac(hostAddr.addr, addr);
//     SleErrorCode ret = g_SleHost->GetHostAddress(hostAddr);

//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }


/******************************************************************************************************************** */
// 测试设置主机名
// HWTEST_F(HostHandlerTest, SetHostNameTest002, TestSize.Level1) {
//     std::string validName = "ValidHostName";
//     SleErrorCode ret = g_SleHost->SetHostName(validName);
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);

//     std::string emptyName = "";
//     ret = g_SleHost->SetHostName(emptyName);
//     EXPECT_EQ(ret, SLE_ERR_INVALID_PARAM);
// }

/******************************************************************************************************************** */
// 测试获取主机名
// HWTEST_F(HostHandlerTest, GetHostNameTest002, TestSize.Level1) {
//     std::string hostName;
//     SleErrorCode ret = g_SleHost->GetHostName(hostName);
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }


/******************************************************************************************************************** */
// 测试获取默认连接配置
HWTEST_F(HostHandlerTest, GetHostDefaultConnectConfigTest001, TestSize.Level1) {
    SleConnectConfig config;
    SleErrorCode ret = g_SleHost->GetHostDefaultConnectConfig(config);
    EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);

}

/******************************************************************************************************************** */
// 测试启动流量监控
// HWTEST_F(HostHandlerTest, StartFlowMonitorTest001, TestSize.Level1) {
//     SleErrorCode ret = g_SleHost->StartFlowMonitor();
//     EXPECT_EQ(ret, SLE_ERR_CHECKOUT_FAILED);
// }
/******************************************************************************************************************** */


// 测试注册回调
HWTEST_F(HostHandlerTest, RegisterHostCallbackTest001, TestSize.Level1) {
    SleErrorCode ret = g_SleHost->RegisterHostCallback(g_Callback);
    EXPECT_EQ(ret, SLE_ERR_INVALID_PARAM);
}

// 测试注销回调
HWTEST_F(HostHandlerTest, UnregisterHostCallbackTest001, TestSize.Level1) {
    SleErrorCode ret = g_SleHost->UnregisterHostCallback(g_Callback);
    EXPECT_EQ(ret, SLE_ERR_INVALID_PARAM);
}

} // namespace SleStandard
} // namespace NearLink
} // namespace OHOS